package org.devocean.groupbuying.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@SuppressWarnings("serial")
@Entity
public class Purchase implements Serializable {

	@Id
	@GeneratedValue
	private Integer purchaseID;
	private Date purchaseDate;
	private Double amount;
	private String purchaseInfo;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "customerID", referencedColumnName = "customerID", nullable = false)
	private Customer customer;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "purchase")
	private Set<PurchaseItem> items = new HashSet<PurchaseItem>();

	public Purchase() {

	}

	public Integer getPurchaseID() {
		return purchaseID;
	}

	public void setPurchaseID(Integer purchaseID) {
		this.purchaseID = purchaseID;
	}

	public Date getPurchaseDate() {
		return purchaseDate;
	}

	public void setPurchaseDate(Date purchaseDate) {
		this.purchaseDate = purchaseDate;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public String getPurchaseInfo() {
		return purchaseInfo;
	}

	public void setPurchaseInfo(String purchaseInfo) {
		this.purchaseInfo = purchaseInfo;
	}

	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	public Set<PurchaseItem> getItems() {
		return items;
	}

	public void setItems(Set<PurchaseItem> items) {
		this.items = items;
	}

}
